package com.mulanweb.utils;

import java.math.BigDecimal;

/**
 * Created by Administrator on 2016/8/24.
 */
public class NumberFormatterUtil {

    public static float floatLengthController(Float value , int length){
        if(value == null || value <=0 )
            return 0F;
        int   scale  = length ;//设置位数
        int   roundingMode  =  4;//表示四舍五入，可以选择其他舍值方式，例如去尾，等等.
        BigDecimal bd  =   new  BigDecimal((double)value);
        bd   =  bd.setScale(scale,roundingMode);
        value   =  bd.floatValue();
        return value ;
    }
}
